﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace baundSum
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double parityCnt = 10;
            double cnt = 0;
            double sum = 0;
            if (usrParityBtn.Checked) {
                parityCnt = double.Parse(parityTxt.Text);
            }
            cnt += parityCnt;
            sum = double.Parse(baundBox.SelectedItem.ToString());
            sum /= cnt;
            sum /= 1024;
            
            resultText.Text = sum.ToString("f3");
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            baundBox.SelectedIndex = baundBox.Items.IndexOf("9600");
            noParityBtn.Select();
        }

        private void parityTxt_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((!Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;
            }
            else {
                output("请输入数字！");
            }
        }

        private void output(string v)
        {
        }
    }
}
